/**
 *
 * @param  {string} baseUrl
 * @param  {Array} urlMap 现有接口链接
 * @param  {Array} letMap  默认权限
 */

const baseUrl = "/kpi/"

//接口访问权限对应变量
let urlMap = {
  login: baseUrl + 'user/login',
  getInfo: baseUrl + 'authority/info',
  fetchUserList: baseUrl + 'user/userList',
  fetchUserDetail: baseUrl + 'user/userDetail',
  fetchAddUser: baseUrl + 'user/addUserInfo',
  fetchEditorUser: baseUrl + 'user/userUpdate',
  fetchResetUserPwd: baseUrl + 'user/resetUserPassword',
  fetchAddContent: baseUrl + 'user/addContent',
  fetchAuditList: baseUrl + 'audit/auditList',
  fetchLeaderDel: baseUrl + 'audit/groupLeader/delete',
  fetchLeaderChange: baseUrl + 'audit/groupLeader/change',
  fetchCrewList: baseUrl + 'audit/crewList',
  fetchMaterialList: baseUrl + 'material/materialList',
  fetchEditorMaterial: baseUrl + 'material/updateMaterial',
  fetchMaterialContent: baseUrl + 'material/addContent',
  fetchCostList: baseUrl + 'costCenter/list',
  fetchAddCostCenter: baseUrl + 'costCenter/addCostCenter',
  fetchEditorCostCenter: baseUrl + 'costCenter/updateAssociateBrand',
  fetchCostBrandList: baseUrl + 'costCenter/associateBrandList',
  fetchBrandBrandList: baseUrl + 'brand/brandList',
  fetchBrandAddBrand: baseUrl + 'brand/addBrand',
  fetchBrandClassList: baseUrl + 'brand/classList',
  fetchBrandUpdateBrand: baseUrl + 'brand/updateBrand',
  fetchApprovalProgress: baseUrl + 'task/approvalProgress',
  fetchDeleteTask: baseUrl + 'task/deleteTask',
  fetchUpdateMyTask: baseUrl + 'task/updateMyTask',
  fetchTaskAddContent: baseUrl + 'task/taskAddContent',
  fetchTaskHistory: baseUrl + 'task/taskHistory',
  fetchTaskHistoryContent: baseUrl + 'task/taskHistoryContent',
  fetchTaskMyApproval: baseUrl + 'task/myApproval',
  fetchTaskAudit: baseUrl + 'task/taskAudit',
  fetchBrandCommonList: baseUrl + 'task/brandCommonList',
  fetchAddTask: baseUrl + 'task/addTask',
}


//变量与接口名对应
const letMap = {
  fetchAddUser: false,
  fetchEditorUser: false,
  fetchResetUserPwd: false,
  fetchAddContent: false,
  fetchAuditList: false,
  fetchLeaderDel: false,
  fetchLeaderChange: false,
  fetchCrewList: false,
  fetchMaterialList: false,
  fetchEditorMaterial: false,
  fetchMaterialContent: false,
  fetchCostList: false,
  fetchAddCostCenter: false,
  fetchEditorCostCenter: false,
  fetchCostBrandList: false,
  fetchBrandBrandList: false,
  fetchBrandAddBrand: false,
  fetchBrandClassList: false,
  fetchBrandUpdateBrand: false,
  fetchApprovalProgress: false,
  fetchDeleteTask: false,
  fetchUpdateMyTask: false,
  fetchTaskAddContent: false,
  fetchTaskHistory: false,
  fetchTaskHistoryContent: false,
  fetchTaskMyApproval: false,
  fetchTaskAudit: false,
  fetchBrandCommonList: false,
  fetchAddTask: false
}


const SetAccessRule = (urlList, urlMap, letMap) => {
  for (let item in urlList) {
    SetMapRelationTrue(urlList[item].permissionUrl, urlMap, letMap)
  }
  return letMap
}



const SetMapRelationTrue = (url, urlMap, letMap) => {
  for (let item in urlMap) {
    if (url == urlMap[item]) {
      letMap[item] = true
    }
  }

}


export {
  letMap,
  urlMap,
  SetAccessRule,
}